<template>
	<view>
		<template v-if="zxsInfo != null">
			<user-info
				:zxsInfo="zxsInfo" 
				:parScName="parScName"
			></user-info>
			<zxs-info-mod
				:zxsInfo="zxsInfo" 
				:scRange="scRange"
			></zxs-info-mod>
			<template v-if="roleName == ''">
				<view class="botBtnGroup hasFlex">
					<button class="comBtn" @tap="goYy">立即预约</button>
				</view>
			</template>
			<template v-else>
				<view class="botBtnGroup hasFlex" v-if="roleName == jmRoles">
					<button class="comBtn" @tap="goYy">立即预约</button>
				</view>
				<view class="tips" v-else>注:咨询师预约功能仅限居民用户使用,咨询师/服务工作者暂不支持</view>
			</template>
		</template>
		<template v-else>
			<view class="loadingWrap">
				<loading></loading>
			</view>
		</template>
	</view>
</template>

<script>
	import UserInfo from './components/UserInfo.vue'
	import ZxsInfoMod from '@/components/zxs-archive/zxs-info-mod' 
	import { getWorkerDet } from '@/api/xlzx/index.js'
	export default {
		components:{
			UserInfo,
			ZxsInfoMod
		},
		data(){
			return{
				workerId:0,
				zxsInfo:null,
				parScName:[],
				scRange:[],
				jmRoles:this.jmRole,
				roleName:''
			}
		},
		onLoad(option){
			this.workerId = option.workerId;
			wx.showShareMenu({
				withShareTicket: true,
				menus: ['shareAppMessage', 'shareTimeline'],
			})
			this.getList();
		},
		onShow(){
			this.roleName = uni.getStorageSync('roleName');
		},
		methods:{
			onShareAppMessage(res){
				return{
					title:this.zxsInfo.userName + '咨询师详情',
					imageUrl:this.zxsInfo.zjImg
				}
			},
			getList(){
				let field = { id:this.workerId,opt:1 }
				getWorkerDet(field).then(res=>{
					//console.log(res)
					this.zxsInfo = res.data.datas;
					for(var i=0;i<this.zxsInfo.scRangeList.length;i++){
						this.scRange.push(this.zxsInfo.scRangeList[i]);
						this.parScName.push(this.zxsInfo.scRangeList[i].parentLyName);
					}
				}).catch(err=>{ 
					console.log(err)
				});
			},
			goYy(){
				if(uni.getStorageSync('userIdZz')){
					uni.navigateTo({
						url:'/pages/subZx/zxsYy/zxsYy?zxsUserId=' + this.zxsInfo.zxsUserId
					})
				}else{
					uni.navigateTo({
						url:'/pages/login/login?loginNum=0'
					})
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.botBtnGroup{
		width: 100%;
		height: 120rpx;
		position: sticky;
		bottom: 0;
		background: #fff;
		box-shadow: 0 -10rpx 10rpx rgba(127, 188, 255, .1);
		align-items: center;
		--sonHei:80rpx;
		.btnGroup{
			width: 260rpx;
			height: var(--sonHei);
			display: flex;
			.groupItem{
				flex: 1;
				text-align: center;
				font-size: 26rpx;
				color: $pss-text-color0;
				.test{
					width: calc(var(--sonHei)/2);
					height:calc(var(--sonHei)/2);
					background: pink;
					margin: 0 auto 5rpx;
				}
			}
		}
		.comBtn{
			flex: 1;
			height: var(--sonHei);
			margin:0 20rpx;
			border-radius: 50rpx;
			line-height: var(--sonHei);
			font-size: 30rpx;
		}
	}
	.tips{
		padding: 0 30rpx 20rpx;
		color: $pss-color-red;
		font-size: 24rpx;
	}
</style>